Skip to content

Conversation

@Lutetium-Vanadium
Copy link
Contributor

Objective

Fixes #876.

Context

From comparing the debug logs between having the container absolute vs in-flow, I noticed that the final_layout_pass was getting no known parent width for absolute but not for in-flow.

Feedback wanted

  • I'm not super familiar with the CSS spec so I'm not sure if this is correct or there is some state that needs to be corrected at a different time.
  • I think there might be a way to remove the duplicate computation by changing the node_inner_size after determine_container_cross_size, but again not familiar with the CSS spec and its under constants so I didn't change it.

@alice-i-cecile alice-i-cecile added the bug Something isn't working label Oct 18, 2025
Copy link
Collaborator

@nicoburns nicoburns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thanks for the PR!

The core idea here looks correct to me (and the Flexbox test backs that up). A couple of comments:

  • I notice you've modified both Flexbox and Block layout, but there is only a test for Flexbox layout. Could you add a test for Block layout too please?
  • Relatedly, Grid layout doesn't have either a test or a fix. Could get a test for Grid layout (and if the test reveals it requires the fix, also the fix)

@Lutetium-Vanadium
Copy link
Contributor Author

Hi, thanks for the feedback. I added the changes you requested. Hope the grid implementation is correct

Copy link
Collaborator

@nicoburns nicoburns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now - thanks!

@nicoburns nicoburns merged commit f99b57f into DioxusLabs:main Oct 20, 2025
26 checks passed
@Hexlord
Copy link

Hexlord commented Nov 7, 2025

Would it make sense to only compute the value of and assign measured_size if known_dimensions is at least partially undefined? Or is it something that should be optimized by the compiler?

I understand absolute positioning is a rare case so it should not matter, and RunMode::ComputeSize is quite a short code path anyway being the extra potentially unnecessary operation, however I also think fully defined size for absolute item is a very common case (it is 100% of cases in our project at least), so it might be worth the branch

@nicoburns
Copy link
Collaborator

Would it make sense to only compute the value of and assign measured_size if known_dimensions is at least partially undefined?

Skipping computing size if a dimension is known is already implemented. As I'd skipping it if it's previously been computed and cached.

However, we still need to lay out the contents of that node if it has any. And the size of those contents are important as they may exceed the size of the container (in which case the node may scroll if configured to do so)

@Hexlord
Copy link

Hexlord commented Nov 7, 2025

Would it make sense to only compute the value of and assign measured_size if known_dimensions is at least partially undefined?

Skipping computing size if a dimension is known is already implemented. As I'd skipping it if it's previously been computed and cached.

However, we still need to lay out the contents of that node if it has any. And the size of those contents are important as they may exceed the size of the container (in which case the node may scroll if configured to do so)

What I meant is this code: https://github.com/DioxusLabs/taffy/pull/878/files#diff-78a705bd422b6ec7ece906ca29973427ec10834766ca5bf1609459f0e4f539d5R2148
The only place the result of that code is used is the following line:
let final_size = known_dimensions.unwrap_or(measured_size).maybe_clamp(min_size, max_size);
And if known_dimensions.x and known_dimensions.y are both already defined, .unwrap_or(measured_size) would have no effect, effectively rendering the initial call to measure_child_size_both useless (it only computes size, it does not contribute to any side effect, at least with regards to the following call to perform_child_layout achieving all the same side effects anyway even with the lack of call to measure_child_size_both).

@nicoburns
Copy link
Collaborator

Ah yes, I see what you mean. That new computations isn't being skipped when it sometimes could be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong size for width 100% when parent is absolute

4 participants